<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>留言板</title>
<%@ include file="../../common_header.jsp"%>
<script type="text/javascript" src="${ctx}/js/other.js"></script>
<style type="text/css" media="screen">
.btn{
   	border-right: #63B8FF 1px solid;
  	padding-right: 2px;
   	border-top: #63B8FF 1px solid;
   	padding-left: 2px;
   	font-size: 12px;
   	FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,  StartColorStr=#ffffff,  EndColorStr=#C3DAF5);
   	border-left: #63B8FF 1px solid;
   	cursor: hand;
   	color: black;
   	padding-top: 2px;
   	border-bottom: #63B8FF 1px solid;
}
</style>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false"
		style="height: 0px; background: #F0FFF0; padding: 5px">
		<form id="formModule" method="post">
    		留言内容：<input id="NAME"  maxlength="10" onchange="searchit();" class="easyui-validatebox textbox" type="text"  name="content" style="width:150px" ></input> 
                                    回复状态：<select id="userId" name="sysUsers.userId" onchange="searchit();">
                            <option value=""  >--全部--</option>
                            <option value="1"  >待回复</option>
                            <option value="9"  >已回复</option>
                        </select>                                    
           	 留言时间从：<input class="easyui-datebox" size="15" name="begin_time" id="begindate"
			data-options="formatter:myformatter,parser:myparser"></input>
			&nbsp;
			到：<input class="easyui-datebox" size="15" name="end_time" id="enddate"
			data-options="formatter:myformatter,parser:myparser"></input> 
    	</form>
		</div>
	<div data-options="region:'center',title:''">
		<table id="dg" class="easyui-datagrid" title="留言板" fit="true"
			style="width: 700px; height: 250px"
			data-options="rownumbers:true,singleSelect:false,url:'/manage/feedBack/dataGrid',method:'get',toolbar:'#toolbar',fit:true,
				showFooter:false,pagination:true,idField:'id'">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true">全选</th>
					<!-- <th data-options="field:'sysCustomer',width:100,align:'center',formatter:showName">反馈人</th> -->
					<th data-options="field:'content',width:300,align:'center'">留言内容</th>
					<th data-options="field:'phone',width:130,align:'center'">联系方式</th>
					<th data-options="field:'createTime',width:150,align:'center',formatter:formatDate">反馈时间</th>
					<th data-options="field:'sysUsers',width:120,align:'center',formatter:showNames">回复人（回复状态）</th>
					<th data-options="field:'returContent',width:300,align:'center'">回复内容</th>
					<th data-options="field:'updateTime',width:150,align:'center',formatter:formatDate">回复时间</th>
					<th data-options="field:'status',width:70,align:'center',formatter:showFlag">状态</th>
					<th data-options="field:'_operate',width:120,align:'center',formatter:formatOper">操作</th>
				</tr>
			</thead>
		</table>
		<div id="toolbar" style="height: auto;background: #F0FFF0">
			${buttons }
			<script type="text/javascript">
				function edit() {
					 	var id=0;
		                var name=null;
		                var row = $('#dg').datagrid('getSelected');
		            	var len = $('#dg').datagrid('getSelections').length; 
		               	if(len>1){
		               		$.messager.alert("系统提示","只能选择一个进行回复!",'info');
		               	}
		               	else if(len==1 && row)
		                {
		                    id = row.id;
		                    name = row.name;
		                        var params = {
		                                winId:'addEditObjWin',
		                                title:'回复',
		                                width:300,
		                                height:250,
		                                showUrl:'${ctx}/manage/feedBack/edit?id='+id,
		                                refresh_fun:function(){
		                                	$('#dg').datagrid('uncheckAll');
		                                    $('#dg').datagrid('reload');
		                                }
		                        };
		                        open_fun(params);   
		                }           
		                else
		                {
		                    $.messager.alert("提示","请选择要回复的信息!",'info');
		                }
				}
				function removeit() {
					var ids = [];
		        	var rows = $('#dg').datagrid('getSelections');
		        	var len = $('#dg').datagrid('getSelections').length; 
		        	for(var i=0; i<rows.length; i++){
		        		ids.push(rows[i].id);
		        	}
		            if(!len)
		            {
		                $.messager.alert("提示","请选择要移除的数据！",'info');
		            }
		            else
		            {
		                $.messager.confirm("移除确认","是否要移除你选择的数据到回收站？",function(conf){
		                    if(conf)
		                    {
		                        var url = "${ctx}/manage/feedBack/remove?ids="+ids;
		                        $.getJSON(url, function(json){
		                            if(json.success==0)
		                            {
		                            	
		                            	$('#dg').datagrid('uncheckAll');
		                                $('#dg').datagrid('reload');
		                            }
		                            else
		                            {
		                                showErrMsg(json);
		                            }
		                        });
		                    }                                       
		                });
		            }
				}
				function searchit() {
					$("#dg").datagrid("load", sy.serializeObject($('#formModule').form()));
				}
				//右侧菜单
				function formatOper(val, row, index) {
					return '<a href="#" onclick="editone();"><input class="btn" type="button" value="回复" ></a>  <a href="#" onclick="removeone();"><input class="btn" type="button" value="移除" ></a>';
				}
				 //以下两个函数为单个操作
		        function editone(){
		        	//alert(row);
		        	var row = $('#dg').datagrid('getSelected');
		        	var id = row.id;
		            //winId,title,width,height,showUrl,okUrl,refresh_fun
		            var params = {
		                    winId:'addEditObjWin',
		                    title:'回复',
		                    width:300,
		                    height:250,
		                    showUrl:'${ctx}/manage/feedBack/edit?id='+id,
		                    refresh_fun:function(){
		                    	$('#dg').datagrid('uncheckAll');
		                        $('#dg').datagrid('reload');
		                    }
		                    
		            };
		            open_fun(params);   
		        	
		        }
		        function removeone(){
		        	var row = $('#dg').datagrid('getSelected');
		        	var id = row.id;
		        	 $.messager.confirm("移除确认",'移除该条反馈&nbsp;？',function(conf){
		                 if(conf)
		                 {
		                     var url = "${ctx}/manage/feedBack/remove?ids="+id;
		                     $.getJSON(url, function(json){
		                         if(json.success==0)
		                         {
		                         	
		                         	$('#dg').datagrid('uncheckAll');
		                             $('#dg').datagrid('reload');
		                         }
		                         else
		                         {
		                             showErrMsg(json);
		                         }
		                     });
		                 }                                       
		             });
		        	
		        }
		        function showFlag(value,rec,index)
		        {
		        	if(value == 9)
		        	{
		        		return "<font color='green'>正常</font>";
		        	}
		        	else if(value == 1)
		        	{
		        		return "<font color='red'>禁用</font>";
		        	}
		        	else if(value == 0){
		        		return "<font color='gray'>移除</font>";
		        	}
		        }
		        function showName(value,rec,index)
		        {
		        	if(value == "" || value == null)
		        	{
		        		return "<font color='red'>未知</font>";
		        	}
		        	else
		        	{
		        		return "<font color='green'>"+value.nickName+"</font>";
		        	}
		        }
		        function showNames(value,rec,index)
		        {
		        	if(value == "" || value == null)
		        	{
		        		return "<font color='gray'>无</font>";
		        	}
		        	else
		        	{
		        		return "<font color='black'>"+value.userName+"</font>";
		        	}
		        }
		        function formatDate (strTime) {
					 var date = new Date(strTime);
					if(strTime == "" || strTime == null ){
						return "";
					}else{
						 return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
					}
		        }
				 $(document).ready(function () {
			        	$("#begindate").datebox({
			        		onChange: function (n,o) {
			        			searchit();
			        		}
			        	});
			        	$("#enddate").datebox({
			        		onChange: function (n,o) {
			        			searchit();
			        		}
			        	});
			        });
			</script>
		</div>
	</div>
	<div id="addEditObjWin" ></div>		<!-- 打开和编辑dialog -->
</body>
</html>